Skip to content

Standardize epochtable() return value handling to always unpack tuple#49

Merged
stevevanhooser merged 3 commits into
mainfrom
claude/fix-timeseries-read-error-9lYWc
Mar 23, 2026
Merged

Standardize epochtable() return value handling to always unpack tuple#49
stevevanhooser merged 3 commits into
mainfrom
claude/fix-timeseries-read-error-9lYWc

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor

Summary

This PR standardizes how the epochtable() method return values are handled across the codebase. The method can return either a tuple or a single value, and this change ensures consistent unpacking behavior.

Key Changes

  • src/ndi/element/functions.py: Updated _get_epoch_table() to handle both tuple and non-tuple return values from epochtable(), extracting the first element when a tuple is returned
  • src/ndi/fun/probe/export_binary.py: Changed from conditional tuple checking to direct tuple unpacking (et, _ = probe.epochtable())
  • src/ndi/epoch/functions.py: Updated epochrange() to unpack tuple return value from epochtable()
  • src/ndi/probe/timeseries.py: Updated _readtimeseries_via_syncgraph() to unpack tuple return value
  • src/ndi/probe/timeseries_mfdaq.py: Updated getchanneldevinfo() to unpack tuple return value

Implementation Details

The changes assume that epochtable() consistently returns a tuple where the first element is the epoch table data and the second element (discarded with _) is additional metadata. The centralized handling in _get_epoch_table() provides a fallback for cases where the return value might not be a tuple, improving robustness while other call sites are updated to expect the tuple format directly.

https://claude.ai/code/session_017Sfgtomgo9AEEGfKP57eJZ

claude added 3 commits March 22, 2026 23:37
epochtable() returns (list, hash) but getchanneldevinfo() and
_readtimeseries_via_syncgraph() assigned the tuple directly to et,
causing et[epoch-1] to return the list instead of a dict entry,
leading to AttributeError: 'list' object has no attribute 'get'.

https://claude.ai/code/session_017Sfgtomgo9AEEGfKP57eJZ
- epoch/functions.py:epochrange() - was not unpacking tuple
- element/functions.py:_get_epoch_table() - could return tuple to
  callers expecting a list; now handles both return types
- fun/probe/export_binary.py - replace ad-hoc isinstance check with
  proper tuple unpacking

https://claude.ai/code/session_017Sfgtomgo9AEEGfKP57eJZ
epochrange() accepts any object with an epochtable() method, which may
return either a tuple (epochset subclasses) or a plain list (daq/navigator).
Use isinstance check to handle both cases.

https://claude.ai/code/session_017Sfgtomgo9AEEGfKP57eJZ
@stevevanhooser stevevanhooser merged commit c39c2ac into main Mar 23, 2026
5 checks passed
@stevevanhooser stevevanhooser deleted the claude/fix-timeseries-read-error-9lYWc branch March 23, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants